package com.hs.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.hs.room.model.archive.ArchiveStatus
import kotlinx.coroutines.flow.Flow

@Dao
interface ArchiveStatusDao {

    @Insert
    suspend fun insert(d: ArchiveStatus)

    @Update
    suspend fun update(d: ArchiveStatus): Int

    @Query("SELECT * FROM archive_status where :name = asName")
    fun selectByName(name: String): ArchiveStatus

    @Query("SELECT * FROM archive_status")
    fun getAll(): Flow<List<ArchiveStatus>>

    @Query("SELECT * FROM archive_status ORDER BY localId LIMIT :limit OFFSET :offset ")
    fun get(limit: Int, offset: Int): Flow<List<ArchiveStatus>>

    @Query("SELECT count(*) FROM archive_status")
    fun count(): Int

    @Delete
    suspend fun delete(d: ArchiveStatus)

}